{extend name="$base" /}
{block name="resources"}
<link rel="stylesheet" type="text/css" href="ADMIN_CSS/member_list.css" />
<script type="text/javascript" src="__STATIC__/My97DatePicker/WdatePicker.js"></script>

{/block}
{block name="main"}
<table class="mytable">
	<tr>
		<th width="20%" style="text-align: left;">
			<button class="btn-common btn-small" onclick="release_coin()">一键释放</button>
		</th>

		<th>
			<select id="order_by"  class="select-common middle">
				<option value ="balance">{:lang("member_balance")}</option>
				<option value ="salary">{:lang("member_coin")}</option>
				<option value ="point">{:lang("member_integral")}</option>
			</select>
			<select id="asc"  class="select-common middle">
				<option value ="desc">降序</option>
				<option value ="asc">升序</option>
			</select>
			<input type="button" onclick="searchData()" value="搜索" class="btn-common" />

		</th>
	</tr>
</table>
<table class="table-class" >
	<thead>
		<tr align="center">
			<th>序号</th>
			<th class="tal">会员</th>
			<th class="tal">{:lang('member_balance')}</th>
			<th class="tal">{:lang("member_coin")}</th>
			<th class="tal">{:lang("member_integral")}</th>
			<th class="tal">操作</th>
		</tr>
	</thead>
	<tbody id="my-table"></tbody>
</table>
{/block}
{block name="script"}
<script type="text/javascript">
    function LoadingInfo(page_index) {
        var order_by = $("#order_by").val();
        var asc = $("#asc").val();
        $.ajax({
            type : "post",
            url : document.location,
            data : {
                "page_index" : page_index,
                "page_size" : $("#showNumber").val(),
				"order_by":order_by,
				"asc" : asc
            },
            success : function(data) {
                if (data["data"].length > 0) {
					const today_time = new Date(new Date().toDateString()).getTime()/ 1000;
                    $("#my-table").empty();
                    for (var i = 0; i < data["data"].length; i++) {
                        var html = '';
                        html += '<tr align="center">';
                        html += '<td class="tal" >'+ data["data"][i]["uid"] +'</td>'
                        html += '<td class="tal"><a onclick=view_member('+data["data"][i]["uid"]+')>'+ data["data"][i]["nick_name"] +'<br>'+ data["data"][i]["user_name"]+'<br>'+ data["data"][i]["user_tel"] +'</a></td>'
                        html += '<td class="tal">'+ data["data"][i]["balance"] +'</td>'
						html += '<td class="tal">'+ data["data"][i]["coin"] +'</td>'
						html += '<td class="tal">'+ data["data"][i]["point"] +'</td>'
						html += '<td>';
						if(data["data"][i]["salary"] > 0 )
						//if(data["data"][i]["salary"] > 0 && data["data"][i]["last_release_time"] != today_time)
						{
							html += '<a onclick="release_record('+ data["data"][i]["id"]+')">释放</a>';
						}
						html += '</td>';
                        $("#my-table").append(html);
                    }
                } else {
                    var html = '<tr align="center"><td colspan="10">暂无符合条件的数据记录</td></tr>';
                    $("#my-table").html(html);
                }
                initPageData(data["page_count"],data['data'].length,data['total_count']);
                $("#pageNumber").html(pagenumShow(jumpNumber,$("#page_count").val(),{$pageshow}));
            }
        });
    }
    //搜索
    function searchData(){
        LoadingInfo(1);
    }


	function release_record(id) {
		$( "#dialog" ).dialog({
			buttons: {
				"确定": function() {
					$.ajax({
						type : "post",
						url : "{:__URL('ADMIN_MAIN/Mine/releaseFrozenCoin')}",
						data : { "id" : id },
						dataType : "json",
						success : function(data) {
							if(data["code"] > 0 ){
								LoadingInfo(getCurrentIndex(id,'#productTbody'));
								showTip(data["message"],'success');
								$("#chek_all").prop("checked", false);
							}else{
								showTip(data["message"],'error');
							}
						}
					});
					$(this).dialog('close');
				},
				"取消,#e57373": function() {
					$(this).dialog('close');
				},
			},
			contentText:"确定要对该条记录手动加速释放吗？",
		});
	}


	function release_coin() {
		$( "#dialog" ).dialog({
			buttons: {
				"确定": function() {
					$.ajax({
						type : "post",
						url : "{:__URL('ADMIN_MAIN/Mine/releaseFrozenCoinAll')}",
						dataType : "json",
						success : function(data) {
							if(data["code"] > 0 ){
								LoadingInfo(1);
								showTip(data["message"],'success');
								$("#chek_all").prop("checked", false);
							}else{
								showTip(data["message"],'error');
							}
						}
					});
					$(this).dialog('close');
				},
				"取消,#e57373": function() {
					$(this).dialog('close');
				},
			},
			contentText:"确定要一键结算今天的加速释放吗？",
		});
	}
</script>
{/block}
